package com.alkin.thing.project.common;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.Field;

@Slf4j
public class ObjectUtils {

	private ObjectUtils() {
	}

	/**
	 * 判断类中每个属性是否都为空(本方法只对String类型进行有效判断)
	 *
	 * @param o
	 * @return
	 */
	public static boolean allFieldIsNULL(Object o) {
		try {
			for (Field field : o.getClass().getDeclaredFields()) {
				field.setAccessible(true);

				Object object = field.get(o);
				if (object instanceof CharSequence) {
					if (!org.springframework.util.ObjectUtils.isEmpty(object)) {
						return false;
					}
				} else {
					if (null != object) {
						return false;
					}
				}
			}
		} catch (Exception e) {
			log.error("判断对象属性为空异常", e);

		}
		return true;
	}
}